const Router = require('koa-router')
const callCloudDB = require('../../../core/callCloudDB.js')
const cloudStorage = require('../../../core/callCloudStorage.js')
// get post

const router = new Router({
    prefix: '/v1/setting'
})

router.get('/list', async (ctx, next) => { //列表
    const params = ctx.request.query
    const query = `
        db.collection('blogShow').get()
    `
    const res = await callCloudDB(ctx, 'databasequery', query)
    let data = res.data.map(item => JSON.parse(item))

    ctx.body = {
        code: 200,
        data
    }
})

router.get('/update', async (ctx, next) => {
    const params = ctx.request.query
    const query = `
        db.collection('blogShow').doc('${params._id}').update({
            data: {
                blogshow: ${params.blogshow},
            }
        })
    `
    const res = await callCloudDB(ctx, 'databaseupdate', query)
    ctx.body = {
        code: 200,
        data: res
    }
})

module.exports = router